package org.jeecg.modules.job.sub.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.modules.job.sub.entity.SubAnswerRecords;
import org.jeecg.modules.job.sub.mapper.SubAnswerRecordsMapper;
import org.jeecg.modules.job.sub.service.ISubAnswerRecordsService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

/**
 * @Description: 答题结果
 * @Author: jeecg-boot
 * @Date:   2022-10-15
 * @Version: V1.0
 */
@Service
public class SubAnswerRecordsServiceImpl extends ServiceImpl<SubAnswerRecordsMapper, SubAnswerRecords> implements ISubAnswerRecordsService {

    @Override
    public boolean addOrUpdate(SubAnswerRecords records) {
        SubAnswerRecords result=this.getOne(new QueryWrapper<>(new SubAnswerRecords().setUserId(records.getUserId()).setTitleId(records.getTitleId()).setPhaseId(records.getPhaseId())));
        if (result!=null){
            records.setId(result.getId());
            this.updateById(records);
        }else{
            this.save(records);
        }
        return true;
    }
}
